import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pet_app/model/enums/pet_type.dart';

import 'logic.dart';

class HomePage extends StatelessWidget {
  HomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final logic = Get.find<HomeLogic>();
    return SafeArea(
        child: Container(
      decoration: const BoxDecoration(
          gradient: LinearGradient(colors: [
        Colors.amberAccent,
        Colors.redAccent,
        Colors.deepOrangeAccent
      ], begin: Alignment.topLeft, end: Alignment.bottomRight)),
      child: Column(
        children: [
          const SizedBox(
            height: 60,
          ),
          _buildBtn('assets/images/business/dog.png', PetType.dog, logic),
          _buildBtn('assets/images/business/cat.png', PetType.cat, logic),
          const SizedBox(
            height: 60,
          )
        ],
      ),
    ));
  }

  Widget _buildBtn(String img, PetType petType, HomeLogic logic) {
    return Expanded(
      child: Center(
        child: Material(
          color: Colors.transparent,
          shape: const CircleBorder(),
          child: InkWell(
            onTap: () => logic.toMenuPanelPage(petType,img),
            borderRadius: BorderRadius.circular(100),
            child: Padding(
              padding: const EdgeInsets.all(10.0),
              child: Container(
                width: 120,
                height: 120,
                decoration: BoxDecoration(
                  boxShadow: [
                    BoxShadow(
                      color: Colors.black54.withOpacity(0.5), // 阴影颜色
                      spreadRadius: 2,
                      blurRadius: 12, // 阴影模糊程度
                      offset: const Offset(1, 3), // 阴影偏移量
                    ),
                  ],
                  shape: BoxShape.circle,
                  border: Border.all(width: 3, color: Colors.black38),
                ),
                child: CircleAvatar(
                  backgroundImage: AssetImage(img),
                  radius: 60,
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
}
